package kn.cstf2.cop.Server;

import kn.cstf2.implementation.Server.*;
import kn.cstf2.cop.Bean.CopBean;
import kn.cstf2.transition.Server.*;
import kn.cstf2.login.Server.*;
import kn.cstf2.global.Utils.*;
import kn.cstf2.login.Server.*;
import kn.cstf2.global.Utils.CstF2Exception;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import kn.cstf2.cop.Bean.*;
import kn.cstf2.implementation.Bean.*;
import kn.cstf2.transition.Bean.TransitionBean;
//import kn.cstf2.transition.Bean.*;

/**
 * @author Izhar Gamaliel Hernandez Cruz Programador Java Junior Desarrollado
 * para Kuehne + Nagel
 */
public class AdaptadorCop {



    public static CopBean obtenerDataFromCop(ResultSet rs) {
        CopBean copBean = new CopBean();
        try {
            if (rs.next()) {
                copBean.setId(rs.getInt("id"));
                copBean.setExport(rs.getBoolean("export"));
                copBean.setOverview(rs.getString("overview"));
                copBean.setFcl(rs.getBoolean("fcl"));
                copBean.setLcl(rs.getBoolean("lcl"));
                copBean.setPerishables(rs.getBoolean("perishables"));
                copBean.setBrokerage(rs.getBoolean("brokerage"));
                copBean.setIntermodal(rs.getBoolean("intermodal"));
                copBean.setInsurance(rs.getBoolean("insurance"));
                copBean.setOceanfreight(rs.getBoolean("oceanfreight"));
                copBean.setBlueancorline(rs.getBoolean("blueancorline"));
                copBean.setSeatransport(rs.getBoolean("seatransport"));
                copBean.setExportcustoms(rs.getBoolean("exportcustoms"));
                copBean.setInbondexp(rs.getBoolean("inbondexp"));
                copBean.setImportcustoms(rs.getBoolean("importcustoms"));
                copBean.setInbondim(rs.getBoolean("inbondim"));
                copBean.setPreallmotor(rs.getBoolean("preallmotor"));
                copBean.setPrecombined(rs.getBoolean("precombined"));
                copBean.setOnallmotor(rs.getBoolean("onallmotor"));
                copBean.setOncombined(rs.getBoolean("oncombined"));
                copBean.setOriginconditions(rs.getString("originconditions"));
                copBean.setDestconditions(rs.getString("destconditions"));
                copBean.setWorkinst(rs.getString("workinst"));
                copBean.setAttachedfiles(rs.getInt("attachedfiles"));
                copBean.setRequirements(rs.getString("requirements"));
                copBean.setPickuptosiling(rs.getBoolean("pickuptosiling"));
                copBean.setCustomsclearance(rs.getBoolean("customsclearance"));
                copBean.setMaincarriage(rs.getBoolean("maincarriage"));
                copBean.setArrivaltocustoms(rs.getBoolean("arrivaltocustoms"));
                copBean.setArrivaltodelivery(rs.getBoolean("arrivaltodelivery"));
                copBean.setEscortkn(rs.getBoolean("escortkn"));
                copBean.setEscortclient(rs.getBoolean("escortclient"));
                copBean.setProtocol(rs.getString("protocol"));
                copBean.setIdtransitioncop(rs.getInt("idtransitioncop"));
                copBean.setPrecarrier(rs.getBoolean("precarrier"));
                copBean.setOncarriage(rs.getBoolean("oncarriage"));
            }
        } catch (SQLException ex) {
            
            throw new CstF2Exception("No se pudo obtener la informacion del Usuario");
        }
        return copBean;
    }

    public static CopBean obtenerIdDesdeCop(ResultSet rs) {
        CopBean copBean = new CopBean();
        try {
            if (rs.next()) {
                copBean.setId(rs.getInt("id"));

            }
        } catch (SQLException ex) {
            
            throw new CstF2Exception("No se pudo obtener la informacion del Usuario");
        }
        return copBean;
    }

    public static ArrayList<ExceptionBean> obtenerExceptions(ResultSet rs) {

        ArrayList<ExceptionBean> exceptionList = new ArrayList<ExceptionBean>();
        try {
            while (rs.next()) {
                ExceptionBean exceptionBean = new ExceptionBean();

                exceptionBean.setId(rs.getInt("id"));
                exceptionBean.setIdcop(rs.getInt("idcop"));
                exceptionBean.setExceptcode(rs.getString("exceptcode"));
                exceptionBean.setExceptlogic(rs.getString("exceptlogic"));

                exceptionList.add(exceptionBean);


            }
        } catch (SQLException ex) {
            throw new CstF2Exception("No se pudo obtener la informacion del Usuario");
        }
        return exceptionList;
    }

    public static T_customer_solutionBeanSTK obtenerCustomerSolutionStk(ResultSet rs) {

        T_customer_solutionBeanSTK t_customer_solutionBeanSTK = new T_customer_solutionBeanSTK();
        try {
            while (rs.next()) {

                t_customer_solutionBeanSTK.setAfaBooked(rs.getString(1));
                t_customer_solutionBeanSTK.setAfaPickup(rs.getString(2));
                t_customer_solutionBeanSTK.setAfaEtsExchanged(rs.getString(3));
                t_customer_solutionBeanSTK.setAfaShipped(rs.getString(4));
                t_customer_solutionBeanSTK.setAfaEtaExchanged(rs.getString(5));
                t_customer_solutionBeanSTK.setAfaArrived(rs.getString(6));
                t_customer_solutionBeanSTK.setAfaDelivered(rs.getString(7));
                t_customer_solutionBeanSTK.setAfaOther(rs.getString(8));
                t_customer_solutionBeanSTK.setAfaDetailOther(rs.getString(9));
                t_customer_solutionBeanSTK.setAfsBooked(rs.getString(10));
                t_customer_solutionBeanSTK.setAfsPickup(rs.getString(11));
                t_customer_solutionBeanSTK.setAfsEtsExchanged(rs.getString(12));
                t_customer_solutionBeanSTK.setAfsShipped(rs.getString(13));
                t_customer_solutionBeanSTK.setAfsEtaExchanged(rs.getString(14));
                t_customer_solutionBeanSTK.setAfsArrived(rs.getString(15));
                t_customer_solutionBeanSTK.setAfsDelivered(rs.getString(16));
                t_customer_solutionBeanSTK.setAfsOther(rs.getString(17));
                t_customer_solutionBeanSTK.setAfsDetailOther(rs.getString(18));
                t_customer_solutionBeanSTK.setAfoBooked(rs.getString(19));
                t_customer_solutionBeanSTK.setAfoPickup(rs.getString(20));
                t_customer_solutionBeanSTK.setAfoEtsExchanged(rs.getString(21));
                t_customer_solutionBeanSTK.setAfoShipped(rs.getString(22));
                t_customer_solutionBeanSTK.setAfoEtaExchanged(rs.getString(23));
                t_customer_solutionBeanSTK.setAfoArrived(rs.getString(24));
                t_customer_solutionBeanSTK.setAfoDelivered(rs.getString(25));
                t_customer_solutionBeanSTK.setAfoOther(rs.getString(26));
                t_customer_solutionBeanSTK.setAfoDetailOther(rs.getString(27));

                t_customer_solutionBeanSTK.setRfaOe(rs.getString(28));
                t_customer_solutionBeanSTK.setRfaFin(rs.getString(29));
                t_customer_solutionBeanSTK.setRfaVol(rs.getString(30));
                t_customer_solutionBeanSTK.setRfaTt(rs.getString(31));
                t_customer_solutionBeanSTK.setRfaKpis(rs.getString(32));
                t_customer_solutionBeanSTK.setRfaQbrs(rs.getString(33));
                t_customer_solutionBeanSTK.setRfaOther(rs.getString(34));
                t_customer_solutionBeanSTK.setRfaDetailOther(rs.getString(35));

                t_customer_solutionBeanSTK.setRfoOe(rs.getString(36));
                t_customer_solutionBeanSTK.setRfoFin(rs.getString(37));
                t_customer_solutionBeanSTK.setRfoVol(rs.getString(38));
                t_customer_solutionBeanSTK.setRfoTt(rs.getString(39));
                t_customer_solutionBeanSTK.setRfoKpis(rs.getString(40));
                t_customer_solutionBeanSTK.setRfoQbrs(rs.getString(41));
                t_customer_solutionBeanSTK.setRfoOther(rs.getString(42));
                t_customer_solutionBeanSTK.setRfoDetailOther(rs.getString(43));

                t_customer_solutionBeanSTK.setRfsOe(rs.getString(44));
                t_customer_solutionBeanSTK.setRfsFin(rs.getString(45));
                t_customer_solutionBeanSTK.setRfsVol(rs.getString(46));
                t_customer_solutionBeanSTK.setRfsTt(rs.getString(47));
                t_customer_solutionBeanSTK.setRfsKpis(rs.getString(48));
                t_customer_solutionBeanSTK.setRfsQbrs(rs.getString(49));
                t_customer_solutionBeanSTK.setRfsOther(rs.getString(50));
                t_customer_solutionBeanSTK.setRfsDetailOther(rs.getString(51));


                t_customer_solutionBeanSTK.setAdReqFaOms(rs.getString(52));
                t_customer_solutionBeanSTK.setAdReqFaMms(rs.getString(53));
                t_customer_solutionBeanSTK.setAdReqFaWebBooking(rs.getString(54));
                t_customer_solutionBeanSTK.setAdReqFaIdp(rs.getString(55));
                t_customer_solutionBeanSTK.setAdReqFaAdStatus(rs.getString(56));
                t_customer_solutionBeanSTK.setAdReqFaDashboard(rs.getString(57));
                t_customer_solutionBeanSTK.setAdReqFaTransportMan(rs.getString(58));
                t_customer_solutionBeanSTK.setAdReqFaEdiStatus(rs.getString(59));
                t_customer_solutionBeanSTK.setAdReqFaFreightInvoice(rs.getString(60));
                t_customer_solutionBeanSTK.setAdReqFaAsn(rs.getString(61));
                t_customer_solutionBeanSTK.setAdReqFaOther(rs.getString(62));
                t_customer_solutionBeanSTK.setAdReqFaOtherDetail(rs.getString(63));

                t_customer_solutionBeanSTK.setAdReqFsOms(rs.getString(64));
                t_customer_solutionBeanSTK.setAdReqFsMms(rs.getString(65));
                t_customer_solutionBeanSTK.setAdReqFsWebBooking(rs.getString(66));
                t_customer_solutionBeanSTK.setAdReqFsIdp(rs.getString(67));
                t_customer_solutionBeanSTK.setAdReqFsAdStatus(rs.getString(68));
                t_customer_solutionBeanSTK.setAdReqFsDashboard(rs.getString(69));
                t_customer_solutionBeanSTK.setAdReqFsTransportMan(rs.getString(70));
                t_customer_solutionBeanSTK.setAdReqFsEdiStatus(rs.getString(71));
                t_customer_solutionBeanSTK.setAdReqFsFreightInvoice(rs.getString(72));
                t_customer_solutionBeanSTK.setAdReqFsAsn(rs.getString(73));
                t_customer_solutionBeanSTK.setAdReqFsOther(rs.getString(74));
                t_customer_solutionBeanSTK.setAdReqFsOtherDetail(rs.getString(75));

                t_customer_solutionBeanSTK.setAdReqFoOms(rs.getString(76));
                t_customer_solutionBeanSTK.setAdReqFoMms(rs.getString(77));
                t_customer_solutionBeanSTK.setAdReqFoWebBooking(rs.getString(78));
                t_customer_solutionBeanSTK.setAdReqFoIdp(rs.getString(79));
                t_customer_solutionBeanSTK.setAdReqFoAdStatus(rs.getString(80));
                t_customer_solutionBeanSTK.setAdReqFoDashboard(rs.getString(81));
                t_customer_solutionBeanSTK.setAdReqFoTransportMan(rs.getString(82));
                t_customer_solutionBeanSTK.setAdReqFoEdiStatus(rs.getString(83));
                t_customer_solutionBeanSTK.setAdReqFoFreightInvoice(rs.getString(84));
                t_customer_solutionBeanSTK.setAdReqFoAsn(rs.getString(85));
                t_customer_solutionBeanSTK.setAdReqFoOther(rs.getString(86));
                t_customer_solutionBeanSTK.setAdReqFoOtherDetail(rs.getString(87));


            }
        } catch (SQLException ex) {
            
            throw new CstF2Exception("No se pudo obtener la informacion del Usuario");
        }
        return t_customer_solutionBeanSTK;
    }

    public static ArrayList<KpiBean> obtenerKpis(ResultSet rs) {

        ArrayList<KpiBean> kpiBeanList = new ArrayList<KpiBean>();
        try {
            while (rs.next()) {
                KpiBean kpiBean = new KpiBean();

                kpiBean.setId(rs.getInt("id"));
                kpiBean.setIdcop(rs.getInt("idcop"));
                kpiBean.setKpicode(rs.getString("kpicode"));
                kpiBean.setKpilogic(rs.getString("kpilogic"));
                kpiBeanList.add(kpiBean);
            }
        } catch (SQLException ex) {
           
            throw new CstF2Exception("No se pudo obtener la informacion del Usuario");
        }
        return kpiBeanList;
    }

    public static ContactsBean obtenerDatosDeContacts(ResultSet rs) {
        ContactsBean contactsBean = new ContactsBean();
        try {
            if (rs.next()) {
                contactsBean.setId(rs.getInt("id"));
                contactsBean.setType(rs.getString("type"));
                contactsBean.setName(rs.getString("name"));
                contactsBean.setPosition(rs.getString("position"));
                contactsBean.setCompany(rs.getString("company"));
                contactsBean.setEmail(rs.getString("email"));
                contactsBean.setPhone(rs.getString("phone"));
                contactsBean.setExtention(rs.getString("extention"));
                contactsBean.setMobile(rs.getString("mobile"));
            }
        } catch (SQLException ex) {
         
            throw new CstF2Exception("No se pudo obtener la informacion del Usuario");
        }
        return contactsBean;
    }

    public static ContactsBean obtenerContact(ResultSet rs) {
        ContactsBean contactsBean = new ContactsBean();
        try {
            contactsBean.setId(rs.getInt("id"));
            contactsBean.setType(rs.getString("type"));
            contactsBean.setName(rs.getString("name"));
            contactsBean.setPosition(rs.getString("position"));
            contactsBean.setCompany(rs.getString("company"));
            contactsBean.setEmail(rs.getString("email"));
            contactsBean.setPhone(rs.getString("phone"));
            contactsBean.setExtention(rs.getString("extention"));
            contactsBean.setMobile(rs.getString("mobile"));
        } catch (SQLException ex) {
            
            throw new CstF2Exception("No se pudo obtener la informacion del Usuario");
        }
        return contactsBean;
    }

    public static Integer obtenerCount(ResultSet rs) {
        Integer count = 0;
        try {
            if (rs.next()) {
                count = (rs.getInt(1));


            }
        } catch (SQLException ex) {
        
            throw new CstF2Exception("No se pudo obtener la informacion del Usuario");
        }
        return count;
    }

    public static T_asignStkBean obtenerIfOwnerFromSTK(ResultSet rs) {
        T_asignStkBean t_asignStkBean = null;
        try {
            if (rs.next()) {
                t_asignStkBean = new T_asignStkBean();
                t_asignStkBean.setIfowner(rs.getString("ifowner"));

            }
        } catch (SQLException ex) {
           
            throw new CstF2Exception("No se pudo obtener la informacion del Usuario");
        }
        return t_asignStkBean;
    }

    public static TransitionsBeanCop obtenerAllDataFromTransitions(ResultSet rs) {
        TransitionsBeanCop transitionsBeanCop = new TransitionsBeanCop();
        try {
            if (rs.next()) {
                transitionsBeanCop.setKnkey(rs.getInt("knkey"));
                transitionsBeanCop.setStatus(rs.getString("status"));
                transitionsBeanCop.setLog(rs.getString("log"));
                transitionsBeanCop.setContacts(rs.getBoolean("contacts"));
                transitionsBeanCop.setContactsdate(rs.getString("contactsdate"));
                transitionsBeanCop.setReporting(rs.getBoolean("reporting"));
                transitionsBeanCop.setReportingdate(rs.getString("reportingdate"));
                transitionsBeanCop.setScopeofservice(rs.getBoolean("scopeofservice"));
                transitionsBeanCop.setScopeofservicedate(rs.getString("scopeofservicedate"));
                transitionsBeanCop.setCondition(rs.getBoolean("condition"));
                transitionsBeanCop.setConditionsdate(rs.getString("conditionsdate"));
                transitionsBeanCop.setCielid(rs.getBoolean("cielid"));
                transitionsBeanCop.setCieliddate(rs.getString("cieliddate"));
                transitionsBeanCop.setCielqmodule(rs.getBoolean("cielqmodule"));
                transitionsBeanCop.setCielqmoduledate(rs.getString("cielqmoduledate"));
                transitionsBeanCop.setAcon(rs.getBoolean("acon"));
                transitionsBeanCop.setAcondate(rs.getString("acondate"));
                transitionsBeanCop.setCarriercc(rs.getBoolean("carriercc"));
                transitionsBeanCop.setCarrierccdate(rs.getString("carrierccdate"));
                transitionsBeanCop.setWorkingst(rs.getBoolean("workingst"));
                transitionsBeanCop.setWorkingstdate(rs.getString("workingstdate"));
                transitionsBeanCop.setSop(rs.getBoolean("sop"));
                transitionsBeanCop.setSopdate(rs.getString("sopdate"));
                transitionsBeanCop.setKpi(rs.getBoolean("kpi"));
                transitionsBeanCop.setKpidate(rs.getString("kpidate"));
                transitionsBeanCop.setBilling(rs.getBoolean("billing"));
                transitionsBeanCop.setBillingdate(rs.getString("billingdate"));

            }
        } catch (SQLException ex) {
            
            throw new CstF2Exception("No se pudo obtener la informacion del Usuario");
        }
        return transitionsBeanCop;
    }
}
